<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>鼓励金兑现</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="__PUBLIC__/static/wx/css/iconfont.css" />
		<link rel="stylesheet" href="__PUBLIC__/static/wx/css/new.css?1=1" />
		<link rel="stylesheet" href="__PUBLIC__/static/wx/css/style.css" />
		<link rel="stylesheet" href="__INDEX__/css/wallet.css" />
		<script src="__INDEX__/js/mui.min.js"></script>
		<link href="__INDEX__/css/mui.min.css" rel="stylesheet" />
	</head>
	<style>
		element.style .mui-content {
			background-color: white;
		}
		
		.tix_num input {
			font-size: 1.2rem;
			width: 80%;
			font-weight: lighter;
			margin-top: 0.2rem;
			border: 0;
			margin-bottom: 8px;
		}
		
		.tix_num img {
			width: 10%; 
			margin-bottom: 8px;
		}
		
		.tx {
			font-size: 1.5rem;
			margin-bottom: 10px;
		}
		.mui-title{
			margin-left: 18px;
		}
		.fake-box input {
		    width: 15.3%;
		    height: 48px;
		    margin: 0;
		    border: none;
		    border-right: 1px solid #e5e5e5;
		    text-align: center;
		    font-size: 30px;
        }
        .mui-bar-nav,.gerzl_btn a{
    	    background-color: #22ab39;
	    }
	</style>

	<body style="background: white;">
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">鼓励金兑现</h1>
		</header>
		<div style="padding: 54px 0 0;">
			<div class="tix_numbox">
				<div class="tx">兑现额度</div>
				<div class="tix_num">
					<label><img src="__PUBLIC__/static/wx/images/glj_tixian.png"></label>
					<input type="text" placeholder="输入兑现数量" onkeyup="key_up(this)" id="much" autocomplete="off"/>
				</div>
				<div class="tips">
					鼓励金数量：<em>{$info_user['score']}</em>
					当前可兑现鼓励金：<em>{$info_user['score']-400}</em>
				</div>
			</div>
			<div class="tix_numbox">
				<div class="tx">实际到账</div>
				<div class="tix_num">
					<label><img src="__PUBLIC__/static/wx/images/glj_money.png"></label>
					<input type="text" placeholder="0" id="tmuch" autocomplete="off"/>
				</div>
				<div class="mui-input-row mui-radio mui-left tips xiey">
					<input name="checkbox" id="checkbox" value="Item 1" type="radio" style="margin-left: -20px;" autocomplete="off">
					<a href="#" style="margin-left: 30px;line-height: 30px;">服务协议</a>
				</div>
			</div>

			<!-- 支付密码 start-->
			<div class="mask" id='pay_by_score'>
				<div class="mask_con">
					<div class="top">
						<span class="del"><button type="button"  onclick="location.reload()">X</button></span>
						<div style="text-align: center;">
							<span class="tx">
							{if count($info_user['logo'])>2}
								<img src="{$info_user['logo']}">
							{else}
								<img src="__INDEX__/images/bgtu.jpg">
							{/if}
						</span>
							<span class="wz">请输入操作密码</span>
						</div>
						<span class="wz" style="width: 45%;"><a href="{:url('member/update_pwd2')}" style="float: right;font-size: 14px;color: red;margin-right: 15px;">忘记密码</a></span>
					</div>
					<div class="xfk_btn" id='is_pay_pwd' style="display: none;">
						<button type="button">设置支付密码</button>
					</div>
					<div class="pwd-box" id='pay_pwd' style="none">
						<input type="tel" maxlength="6" class="pwd-input" id="pwd-input" autocomplete="off">
						<div class="fake-box"> 
							<input type="password" readonly="" autocomplete="off">
							<input type="password" readonly="" autocomplete="off">
							<input type="password" readonly="" autocomplete="off">
							<input type="password" readonly="" autocomplete="off">
							<input type="password" readonly="" autocomplete="off">
							<input type="password" readonly="" autocomplete="off">
						</div>
					</div>
				</div>
			</div>
			<!-- 支付密码 end-->

			<div class="btnbox2"><button type="button" class="dzyhq_btn">兑现</button></div>
			<div class="tuig_tips3">即时到账余额钱包</div>
		</div>

	</body>

</html>
{include file="public/footer" /}
<script>
       var score = "{$info_user['score']}"; 
       var balance = "{$balance}";
		$(function(){
			var is_verify = "{$info_user['is_verify']}";
			if(is_verify != 1){
				layer.msg('请先认证个人信息',function(){
					location.href = "{:url('member/renzhen')}";
				})
			}
		})
	function key_up(obj) {
		obj.value = obj.value.replace(/[^\d]/g, ""); //清除“数字”和“.”以外的字符
		obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字而不是.
		obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的.
		obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
		$("#tmuch").val(parseFloat(obj.value) * 95 / 1000);
	}

	$(".dzyhq_btn").click(function() { 
		if(score <= 400){
			layer.msg('鼓励金余额小于等于400,不能兑现');
			return;
		}
		if($("#much").val() < 100 || $("#much").val() > 20000) {
			layer.msg('鼓励金兑换额度必须大于等于100，小于等于两万');
			return;
		} 
		if(balance >= 50000){
			layer.msg("一天最高提现额度为50000元"); 
			return false;
		}
		//真正能兑现的余额
		if(score - $("#much").val() < 400){
			layer.msg('鼓励金余额不足');
			return;
		}
		//兑现余额取整
		if($("#much").val() % 100 != 0){
			layer.msg('鼓励金兑换必须是100的整数倍');
			return;
		}
		
		if($('#checkbox').is(':checked') == false) {
			layer.msg('请阅读兑现协议');
			return;
		}
		var btnArray = ['我不兑现', '同意兑现'];
		mui.confirm('1  鼓励金余额满400以上方可操作兑现。<br/>2  兑现成功，即时扣掉5%服务费。 ','鼓励金兑换须知', btnArray, function(e) {
			if(e.index == 1) {
				$("#my_form").submit();
				$('#pay_by_score').show();
				var $input = $(".fake-box input");
				$("#pwd-input").on("input", function() {
					var pwd = $(this).val().trim();
					for(var i = 0, len = pwd.length; i < len; i++) {
						$input.eq("" + i + "").val(pwd[i]);
					}
					$input.each(function() {
						var index = $(this).index();
						if(index >= len) {
							$(this).val("");
						}
					});
					var much = $("#much").val();
					var no = $("#no").val();
					if(isNaN(much) || much <= 0) {
						layer.msg("请输入正确兑换到余额金额");
						return;
					}
					if(len == 6) {
						//判断支付密码
						var operate_pwd = "{$info_user['operate_pwd']}";
						if(operate_pwd == ''){
							window.location.href = "{:url('member/update_pwd2?type=1')}";
							return false;
						}
						
						$.ajax({
							url: "{:url('member/glj_tixian')}",
							type: 'post',
							data: {
								much: much,
								pwd: pwd
							},
							success: function(data) { 
								if(data.code == 401){ 
									layer.msg('支付密码错误');
									return false;
								}
								
								layer.msg(data.msg, {
									icon: 1,
									time: 1000
								}, function() {
									window.location.href = "{:url('member/glj')}";
								});
							}
						})
					}
				})

			}
		})
	})
</script>